in this page, you will make your own led circuit.
you will need: 1 led, 1 resistor, 2 wires, 1 breadboard, 1 arduino uno, 1 computer to program the arduino
first, let's understand an led so that we wont accidentally kill it.
as you see from this wikipedia image, the flat side of the led is the negative side of the led. make sure to connect this part to the ground.
from this image, the cathode (negative side) of the led is connected to the GND (known as ground). The anode (postive side) of the led is connected to a resistor and a number (in this case, 2) on the other side of the arduino. The resistor must be placed at the anode side to prevent the current from breaking the led. We will explain more about it in detail later in this page. The next section here will talk about the code
note that all the code here is case sensitive. The way it is coded is very similar to c++, but do note that it isnt c++, nor based off c++. You can, however, make use of a sufficiently good amount of c++ knowledge to help you in coding arudino boards.
"void setup()" here means the inital code, that means this code will only run once at the start of the program.
"pinMode" declares the pin to the respective pin type. for example, this circuit only uses pin 2. the pin types are as follow: OUTPUT, INPUT and INPUT_PULLUP. OUTPUT means that it can only output a result, i.e. whether or not you choose to light up the led. INPUT means it can only take in inputs, i.e. when you type in a number to call someone. INPUT_PULLUP is the same as INPUT, but it "pulls up" the arduino's internal 50k ohm resistor. You use it when there can be a short/open circuit in your circuit.
"void loop()" means that the code in this will run repeatedly, from start to end.
"digitalWrite" can only be used for the pins on the top side of the circuit. The things to write in digitalWrite are the pin number and the state. In the code, you see "digitalWrite(2, HIGH)" and "digitalWrite(2, LOW)". Alternatively, you can use 1 to replace HIGH and 0 to replace LOW.
"delay" here is as it sounds -- it delays the program. it makes the arudino board "sleep" in milliseconds. That means nothing can change or happen during this time period, allowing you to see that the led will light up for 1 seconds before being switched off for 1 seconds.
Here's the original code (with download link at image below!)